package com.kitbox.hl.meshow.datadic.web;

import com.kitbox.hl.meshow.datadic.service.DataDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * @Auther: honglei
 * @Date: 2019/8/21 15:53
 * @Description:
 */
@RequestMapping("/kitbox/datadic/web/")
@Controller
public class DataDicController {
    @Autowired
    private DataDicService dataDicService;

    @RequestMapping(value = "findDataDicPage",method = {RequestMethod.GET,RequestMethod.POST})
   public ModelAndView findDataDicPage(String groud){
        List<Map> mapList=dataDicService.queryDataDic(groud);
        ModelAndView modelAndView=new ModelAndView("dicList");
        modelAndView.addObject(mapList);
        return modelAndView;
    }

    @GetMapping("findDataDic")
    public ModelAndView findDataDic(String groud,String vCode){
        Map map=dataDicService.queryDataDic(groud,vCode);
        ModelAndView modelAndView=new ModelAndView("dicDetail",map);
        return modelAndView;
    }

    @PostMapping("updateOrInsertDataDic")
    public ModelAndView updateOrInsertDataDic(Map map){
        int count=dataDicService.updateOrinsert(map);
        ModelAndView modelAndView=new ModelAndView("/datadicList");
        return modelAndView;
    }


}
